package com.yonyou.brigade.basic_init.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yonyou.brigade.basic_init.dao.BriSysConfigMapper;
import com.yonyou.brigade.basic_init.model.BriSysConfig;
import com.yonyou.brigade.basic_init.service.IBriSysConfigService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 租户全局配置 服务实现类
 * </p>
 *
 * @author kangfw5
 * @since 2019-08-14
 */
@Service
public class BriSysConfigServiceImpl extends ServiceImpl<BriSysConfigMapper, BriSysConfig> implements IBriSysConfigService {

    @Override
    public String getSysConfigValueByKey(String code, String tenantId, String org) {
        Wrapper<BriSysConfig> wrapper = new EntityWrapper<>();

        wrapper.eq(BriSysConfig.CODE, code);
        if (tenantId != null) {
            wrapper.eq(BriSysConfig.TENANTID, tenantId);
        }
        if (org != null) {
            wrapper.eq(BriSysConfig.ORG, org);
        }
        BriSysConfig briSysConfig = this.selectOne(wrapper);
        return briSysConfig == null ? "" : briSysConfig.getValue();
    }
}
